package operatori;

/**
 * @author Sorica Alexandra
 * @date 18.04.2011
 * @version 1.0
 */

public abstract class Produs extends Operator{
	/**
	public double calcul(double aux1, double aux2){
		return aux1 * aux2;
		}
	public static double Calcul(double aux1, double aux2){
		return aux1 * aux2;
		}
	public double calculDerivata(){
		if (ns==null || nd==null)
			System.exit(1);
		return calcul(ns.calculDerivata(), nd.calculDerivata());
		}
	public double calculeazaValoare(){
		if (ns==null || nd==null)
			System.exit(1);
		return calcul(ns.calculeazaValoare(), nd.calculeazaValoare());
		}
	public String derivare(){
		if (ns==null || nd==null)
			System.exit(1);
		return concatTermeni(ns.derivare(), nd.derivare());
		}
		*/
	public String concatTermeni(String a, String b){
		String aux;
		if((a.compareTo("1") == 0 && b.compareTo("1")==0) || a.compareTo("1.0") == 0 || b.compareTo("1.0")==0)
			aux = a;
		else 
			if (a.compareTo("1") == 0) 
				aux = b;
		else 
			if (b.compareTo("1") == 0 ) 
				aux = a;
		else
			aux = a + "*" + b;
		if(a.compareTo("0") == 0 || b.compareTo("0")==0)
            aux="0";
		return aux;
		}
	public static String concatTermens(String a, String b){
		String aux;
		if((a.compareTo("1") == 0 && b.compareTo("1")==0) || a.compareTo("1.0") == 0 || b.compareTo("1.0")==0)
		aux = a;
		else 
			if (a.compareTo("1") == 0) 
				aux = b;
		else 
			if (b.compareTo("1") == 0 ) 
				aux = a;
		else
			aux = a + "*" + b;
		if(a.compareTo("0") == 0 || b.compareTo("0")==0)
            aux="0";
		return aux;
		}

	}
